<template>
  <view>
    <scroll-view scroll-y="true" :scroll-top="scrollTop" @scroll="scroll" class="box">
			<u-button type="primary" class="btn" @click="scrollTopBtn">主</u-button>
		</scroll-view>
	</view >
</template >

<script>
    export default {
		data() {
			return {
				scrollTop: -1
			};
		},
		methods: {
			scroll(e) {
				console.log('滚动的距离： ' + e.detail.scrollTop)
			},
			scrollTopBtn() {
				this.scrollTop = -1
				this.$nextTick(function() {
					this.scrollTop = 0
				})
				console.log(this.scrollTop)
				console.log('设置scrollTop的值为0')
			}
		}
	}
</script>

<style lang="scss">
    .box {
		height: 400rpx;
		border: 1rpx solid red;
	}

	.btn {
		position: absolute;
		top: 200px
	}
</style>
